function* foo() {
  console.log("开始执行");
  let lastValue = 0;

  const value1 = 100;
  console.log(value1);
  lastValue = yield 123;
  console.log(lastValue);

  const value2 = 200;
  console.log(value2);
  lastValue = yield 456;
  console.log(lastValue);

  const value3 = 300;
  console.log(value3);
  lastValue = yield 789;
  console.log(lastValue);

  console.log("执行结束");
}

// 调用
const generator = foo();
console.log(generator.next(111));
console.log(generator.next(222));
console.log(generator.next(333));
console.log(generator.next(444));

